package dao;

	import java.sql.Connection;
	import java.sql.PreparedStatement;
	import java.sql.SQLException;

	import util.ConnectionUtil;

	public class ScoreDao {

		public static void add(int stu_id, int course_id, int score) {
			Connection conn = ConnectionUtil.getConnection();
			String sql = "insert into score (stu_id, course_id, score) VALUES (?, ?, ?)";
			try {
				PreparedStatement ps = conn.prepareStatement(sql);
				ps.setInt(1, stu_id);
				ps.setInt(2, course_id);
				ps.setInt(3, score);
				int result = ps.executeUpdate();
				if(result > 0) {
					System.out.println("选课成功");				
				}else {
					System.out.println("选课失败");
				}
			} catch (SQLException e) {
				
				e.printStackTrace();
			}
			
		}

	}

